#include "Searcher.hpp"
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>

const std::string input = "./data/raw_html/raw.txt"; 
int main()
{
    ns_searcher::Searcher *Ser = new ns_searcher::Searcher();
    Ser->InitSearcher(input);

    std::string json_string;
    std::string quary;
    char buffer[1024];
    while (true)
    {
        std::cout << "Please input Search word# " << std::endl;
        // 不用cin的原因：cin读取不了空格
        fgets(buffer, sizeof(buffer) - 1, stdin);
        buffer[strlen(buffer) - 1] = 0 ;  //去掉读取到的回车
        quary = buffer;   
        Ser->Search(quary, &json_string);
        std::cout << json_string << std::endl;
    }
    return 0;
}
